package frog.lazy.framework.core.tools;

import cn.hutool.core.text.StrBuilder;
import cn.hutool.core.util.StrUtil;
import lombok.SneakyThrows;

public class StrUtils extends StrUtil {

    public static final String SEPARATE_COMMA = ",";

    /**
     *
     * @param isAllowEmpty 是否永许空值
     * @param separate 分格符
     * @param strs 串联字符串
     * @return
     */
    public static String concatSeparate(Boolean isAllowEmpty, CharSequence separate, CharSequence... strs){
        final StrBuilder sb = new StrBuilder();
        for (CharSequence str: strs) {
                if(!isAllowEmpty && isBlank(str)) {
                   continue;
                }
               sb.append(nullToEmpty(str));
               sb.append(separate);
        }
        return sb.subSequence(0, sb.length() - (separate.length())).toString();
    }

    @SneakyThrows
    public static String utf8(String str){
        return new String(str.getBytes("GBK"), "UTF-8");
    }


    public static void main(String args[]){

    }
}
